<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<ul class="shortcut-buttons-set">
				<li>
					<a class="shortcut-button" href='#finance_list/status=0'><span>
					<i class="aicon-task_list"></i>
					<?php echo $this->language['list'];?></span></a>
				</li>
			</ul>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-file-text-alt"></i> <?php echo $this->language['detail'];?></div>
				</div>
				<div class="panel-body">
					<div class="receipt">
						<div class="row">
							<div class="col-lg-8 text-center">
								<b>CÔNG TY TNHH MTV ỨNG DỤNG CÔNG NGHỆ & DV TRUYỀN THÔNG ÂU LẠC</b><br>
								17 Đông Sơn, Phường 7, Quận Tân Bình, TP.Hồ Chí Minh
							</div>
							<div class="col-lg-4 text-center">
								Số phiếu : <font color=red><?php echo $this->phieu['pay_code'];?></font>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-12 text-center">
								<h3>PHIẾU <?php if($this->phieu['pay_type']=='1'){ echo "THU TIỀN MẶT";}else{ echo "CHI";}?></h3>
								<i>Ngày <?php echo date("d",$this->phieu['pay_date']);?> tháng <?php echo date("m",$this->phieu['pay_date']);?> năm <?php echo date("Y",$this->phieu['pay_date']);?></i>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b>Người đứng tên :</b>
							</div>
							<div class="col-lg-8">
								<font color=red><?php echo $this->phieu['pay_name'];?></font>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b>Địa chỉ :</b>
							</div>
							<div class="col-lg-8">
								<font color=red><?php echo $this->phieu['cust_address'];?></font>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b>Dự án :</b>
							</div>
							<div class="col-lg-8">
								<font color=red><?php
									echo $this->phieu['pay_project'];
									if(isset($this->phieu['pay_project_id'])){
										echo ' - <a href="#project_view/pid='.$this->phieu['pay_project_id'].'">'.$this->phieu['pay_project_name'].'</a>';
									}
								?></font>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b>Mã hợp đồng :</b>
							</div>
							<div class="col-lg-8">
								<font color=red><?php echo $this->phieu['pay_contract'];?></font>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b><?php
								if($this->phieu['pay_type']=='0') echo "Lý do";
								elseif($this->phieu['pay_type']=='1') echo "Về khoản";?> :</b>
							</div>
							<div class="col-lg-8">
								<font color=red><?php echo $this->phieu['pay_description'];?></font>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b>Số tiền :</b>
							</div>
							<div class="col-lg-8">
								<font color=red><?php echo number_format($this->phieu['pay_amount'],0,"",",");?></font>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b>Bằng chữ :</b>
							</div>
							<div class="col-lg-8">
								<font color=red><?php echo $this->phieu['bangchu'];?></font>
							</div>
						</div>
						<?php if(count($this->req)>0){ ?>
						<div class="row">
							<div class="col-lg-offset-1 col-lg-3">
								<b>Phiếu tạm ứng :</b>
							</div>
							<div class="col-lg-8">
								<?php
									echo "<ul>";
									foreach($this->req as $row){
										echo "<li><a href='#request_view/id=".$row['req_id']."'>".$row['req_code']." - ".$row['req_reason']."</a></li>";
									}
									echo "</ul>";
								?>
							</div>
						</div>
						<?php } ?>
						<div class="row">
							<div class="col-lg-offset-8 col-lg-4">
								Ngày <font color=red><?php echo date("d",$this->phieu['pay_date']);?></font> Tháng <font color=red><?php echo date("m",$this->phieu['pay_date']);?></font> Năm <font color=red><?php echo date("Y",$this->phieu['pay_date']);?></font>
							</div>
						</div>
					</div>
					<?php if(check_permission('receipt_edit') && ($this->phieu['pay_contract'] == '' || $this->phieu['pay_project'] == '')):?>
					<div class="text-center">
						<a href="javascript:;" data-toggle="modal" data-target="#update_contract" class="btn btn-primary">Cập nhật Mã hợp đồng</a>
						<a href="javascript:;" data-toggle="modal" data-target="#update_project" class="btn btn-primary">Cập nhật Mã dự án</a>
					</div>
					<?php endif;?>
				</div>
			</div>
		</div>
	</div>
	<?php if(check_permission('receipt_edit')){ ?>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-file-text-alt"></i> <?php echo $this->language['attach_request'];?></div>
				</div>
				<div class="panel-body">
					<input type="hidden" id="ptc" value="<?php echo $this->phieu['pay_id'];?>">
					<form action="javascript:doSearchPTU();" class="form-inline">
						<label><?php echo $this->language['search'];?> :</label>
						<input type="text" class="form-control" autocomplete="off" placeholder="<?php echo $this->language['request_code'];?>" id="search_code">
						<input type="text" class="form-control" autocomplete="off" placeholder="<?php echo $this->language['name'];?> / <?php echo $this->language['reason'];?>" id="search_tieuchi">
						<input type="submit" value="<?php echo $this->language['search'];?>" class="btn btn-warning" >
					</form>
					<div id="ptu_result">
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php } ?>
	<div class="modal fade" id="update_contract">
		<div class="modal-dialog">
			<div class="modal-content">
				<form action="javascript:update_contract(<?php echo $this->phieu['pay_id'];?>);">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title">Cập nhật mã hợp đồng</h4>
					</div>
					<div class="modal-body">
						<fieldset>
							<div class="form-group">
								<label for="noteTitle">Mã hợp đồng</label>
								<input type="text" class="form-control" id="contract" placeholder="Mã hợp đồng" />
							</div>
						</fieldset>
					</div>
					<div class="modal-footer">
						<input type="submit" class="btn btn-primary" value="Đồng ý" />
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="modal fade" id="update_project">
		<div class="modal-dialog">
			<div class="modal-content">
				<form action="javascript:update_project(<?php echo $this->phieu['pay_id'];?>);">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title">Cập nhật mã dự án</h4>
					</div>
					<div class="modal-body">
						<fieldset>
							<div class="form-group">
								<label for="noteTitle">Mã dự án</label>
								<input type="text" class="form-control" id="project" placeholder="Mã dự án" />
							</div>
						</fieldset>
					</div>
					<div class="modal-footer">
						<input type="submit" class="btn btn-primary" value="Đồng ý" />
					</div>
				</form>
			</div>
		</div>
	</div>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>